<template>
  <dv-border-box-11 ref="mainBox" title="智慧阴极保护在线监测系统" :title-width="500" class="wholePage">
    <dv-decoration-1 id="decoration_1" style="width:100px;height:50px;" class="decoration" />
    <div class="dashboardBox">
      <div class="dashbordHeader">
        <div id="leftAside" class="asideChart">
          <div class="aboveChart">
            <RegionChart :id="RegionChart" />
          </div>
          <div class="belowChart">
            <LineChart :id="TestChart_1" />
          </div>
        </div>
        <dv-border-box-1 class="chinaMap">
          <div class="chinaMapBody">
            <el-tabs v-model="currentView" @tab-click="handleClick">
              <el-tab-pane label="中国地图" name="ChinaChart" />
              <el-tab-pane label="百度地图" name="baiduMap" />
            </el-tabs>
            <div :is="currentView" keep-alive />
          </div>
        </dv-border-box-1>
        <div id="rightAside" class="asideChart">
          <div class="aboveChart">
            <pllarBarChart :id="TestChart_2" />
            <!--            <show-weather :id="TestChart_2" />-->
          </div>
          <div class="belowChart">
            <StateChart :id="StateChart" />
          </div>
        </div>
      </div>
      <div class="dashbordBody">
        <div class="typeBarChart">
          <TypeBarChart :id="TypeBarChart" />
        </div>
        <div class="realTimeChart">
          <home-real-time-chart id="homeRealTimeChart" />
        </div>
        <div class="scroll-board">
          <scroll-board id="scroll-board" :odd-row-b-g-c="'#1b275e'" :even-row-b-g-c="'#1b275e'" />
        </div>
      </div>
    </div>
  </dv-border-box-11>
</template>

<script>

import StateChart from './components/StateChart'
import TypeBarChart from './components/TypeBarChart'
import HomeRealTimeChart from './components/HomeRealTimeChart.vue'
import RegionChart from './components/RegionChart'
import LineChart from './components/lineChart'
import pllarBarChart from '@/views/dashboard/admin/components/polarBarChart'
import scrollBoard from '@/views/dashboard/admin/components/scrollBoard'
// import showWeather from '@/views/dashboard/admin/components/showWeather'
export default {
  name: 'DashboardAdmin',
  components: {
    RegionChart,
    TypeBarChart,
    StateChart,
    HomeRealTimeChart,
    LineChart,
    pllarBarChart,
    scrollBoard,
    // showWeather,
    // 以下方式引入路由是路由的懒加载，有利于页面优化
    ChinaChart: resolve => {
      require(['./components/ChinaChart.vue'], resolve)
    },
    baiduMap: resolve => {
      require(['./components/baiduMap.vue'], resolve)
    }
  },
  data() {
    return {
      currentView: 'ChinaChart',
      TypeBarChart: 'TypeBarChart',
      RegionChart: 'RegionChart',
      StateChart: 'StateChart',
      TestChart_1: 'TestChart_1',
      TestChart_2: 'TestChart_2',
      homeRealTimeChart: 'homeRealTimeChart',
      resizeObserver: null
    }
  },
  mounted() {
    this.handleResize()
  },
  beforeDestroy() {
    this.resizeObserver.disconnect()
  },
  methods: {
    handleClick(tab, event) {},
    initWH() {
      this.$refs.mainBox.initWH()
    },
    handleResize() {
      this.resizeObserver = new ResizeObserver(() => this.initWH())
      // const resizeObserver = new ResizeObserver(() => setTimeout(() => this.intiWH(), 700))
      this.resizeObserver.observe(document.querySelector('.dashboardBox'))
    }
  }
}
</script>

<style scoped>
.wholePage {
  background-color: #1b275e;
}
#title {
  text-align: center;
  margin-bottom: 1px;
}
.dashboardBox {
  display: flex;
  flex-direction: column;
  padding: 60px 20px 20px;
}
.dashbordHeader {
  display: flex;
  flex: 1;
  height: 700px;
}
.asideChart {
  flex: 1;
  height: 700px;
  padding: 10px 10px 55px;
}
.aboveChart {
  /*height: 325px;*/
  /*width: 250px;*/
  padding: 5px;
  margin-bottom: 20px;
}
.belowChart {
  padding: 10px 5px 5px;
}
#leftAside {
  padding-left: 5px;
}
#rightAside {
  padding-right: 5px;
}
.chinaMap {
  flex: 3;
  /*box-shadow: 0 4px 8px 0 rgba(28, 25, 25, 0.2);*/
  transition: 0.3s;
  width: 100%;
  height: 700px;
  border-radius: 10px;
  box-shadow: 0 8px 16px 0 rgb(21, 20, 20);
}
.chinaMapBody {
  padding: 2px 20px 0;
}
.typeBarChart {
  padding: 10px 5px;
  margin-top: 30px;
}
.realTimeChart {
  padding: 0 5px;
  margin-top: 30px;
}
.scroll-board {
  padding: 0 5px;
  margin-top: 30px;
}
.decoration {
  position: absolute;
  z-index: 99;
}
#decoration_1 {
  right: 20px;
  top: 30px;
}
#showTime {
  position: absolute;
  right: 20px;
}
</style>
